import django_filters
from main.mixins.mixins import OperatorMixins
from rest_framework import serializers, viewsets

from {{ModelName}} import models


class {{ModelName}}Filter(django_filters.rest_framework.FilterSet):
    class Meta:
        model = models.{{ModelName}}
        fields = {
            "create_time": ["range"],
            "operator_name": ["in", "exact"],
        }


class {{ModelName}}Serializer(serializers.ModelSerializer):

    class Meta:
        model = models.{{ModelName}}
        fields = "__all__"
        read_only_fields = ("id", "delete_time")


class {{ModelName}}ViewSet(
    OperatorMixins,
    viewsets.ModelViewSet,
):
    """
    {{ModelName}}管理
    """

    filter_class = {{ModelName}}Filter
    queryset = models.{{ModelName}}.objects.filter()
    serializer_class = {{ModelName}}Serializer
    ordering = ("-id",)

    def get_serializer_class(self):
        return self.serializer_class
